package net.xju3_4.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.xju3_4.common.framework.simplemvc.RequestMapping;
import net.xju3_4.common.utils.JSONUtil;
import net.xju3_4.common.utils.Result;
import net.xju3_4.service.AdminPaymentService;
import net.xju3_4.service.impl.AdminPaymentImpl;

import java.io.UnsupportedEncodingException;
import java.util.Map;

@RequestMapping("/api/admin")
public class AdminPaymentController {
    private AdminPaymentService adminPaymentService=new AdminPaymentImpl();
    @RequestMapping("/statistics.do")
    public void statistics(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException{
        req.setCharacterEncoding("utf-8");
        Map<String, Integer> dict =adminPaymentService.statistics();
        if(dict==null)
            JSONUtil.printByJSON(resp,Result.fail("操作失败"));
        else
        JSONUtil.printByJSON(resp, Result.success(dict));
    }
}
